<?php
namespace app\admin\controller;



use houdunwang\view\View;
use system\model\Admin;


class Login
{
	public function index()
	{

//		$res = Db::table('admin')->get();
//		p($res);


//p(Session::get('admin'));
		if (IS_POST)
		{
			$res = (new Admin())->login();
//				p($res);die;
			if($res['valid'])
			{
				//执行成功
				return message($res['msg'],'admin.entry.index','success');
//				return ['valid'=>1,'message'=>$res['msg']];
			}else{
				//执行失败
				return message($res['msg'],'back','error');
				//return ['valid'=>0,'message'=>$res['msg']];

			}

		}




		//加载模板
		return View::make();
	}
	//显示验证码
	public function code()
	{
		//Code::num(1)->bgColor('#999999')->make();
		Code::num(1)->make();
	}
		//退出
	public function out()
	{
		//清除session
		Session::flush();
		//调转到登录页面
		go('admin.login.index');


	}
}